{mtemplate '_header'}
<div class="dm-subnav">
	<div class="subnav-title">桌号</div>
	<ul>
		<li class="{if $operation == 'display'}active{/if}"><a href="{php echo manage_url(array('r'=>'desk','ac'=>'index','op'=>'display'))}">桌号管理</a></li>
		{if in_array('store_desk_add',$user_permissionArr)}
		<li class="{if $operation == 'post' && empty($id)}active{/if}"><a href="{php echo manage_url(array('r'=>'desk','ac'=>'index','op'=>'post'))}">添加桌号</a></li>
		{/if}
		{if $operation == 'post' && !empty($id)}<li class="active"><a href="{php echo manage_url(array('r'=>'desk','ac'=>'index','op'=>'post','id'=>$id))}">编辑桌号</a></li>{/if}
		
	</ul>
</div>
<div class="dm-container">
<div class="dm-content">
{if $operation == 'display'}
<div class="table-responsive">
	<table class="table we7-table table-hover">
		<thead>
		<tr>
			<!-- <th style="width:40px;">
				<input type="checkbox" name="checkall" value="" id="checkall" onclick="var ck = this.checked; $(':checkbox').each(function(){this.checked = ck});"/>
			</th> -->
			<th style="width:40px;">
				ID
			</th>
			<th style="width:200px;">桌号名称</th>
			<th style="width:180px;" class="text-center">小程序码</th>
			<th class="text-center" style="width:200px;">操作</th>
		</tr>
		</thead>
		<tbody style="background: #fff">
		{if empty($list)}
		<tr><td colspan="4" style="text-align:center">还未添加桌号！<br>自取餐厅无需添加桌号</td></tr>
		{else}
		{loop $list $item}
		<tr>
			<!-- <td><input type="checkbox" name="items[]" value="{$item['id']}" class="items" /></td> -->
			<td style="width:40px;">{$item['id']}</td>
			<td style="width:200px;">{$item['name']}</td>
			<td style="width:180px;" class="text-center">{if !empty($item['wxacode'])}<i class="fa fa-qrcode" style="color: #3e3e3e" data-toggle="popover" data-trigger="click" data-placement="left" data-html="true" data-content="<img style='width:200px;height:200px;' src='{php echo $_W['siteroot'].'addons/deam_food/data/wxacode/'.$item['wxacode']}'><p style='text-align:center;color:#999'>发布后小程序码才能生效</p>"></i>{else}未生成{/if}</td>
			<td class="text-center">
				{if in_array('store_desk_edit',$user_permissionArr)}
				<a href="{php echo manage_url(array('r'=>'desk','ac'=>'index','op'=>'post','id'=>$item['id']))}" class="btn showtitle btn-default btn-sm" title="编辑"><i class="fa fa-edit"></i></a>
				{/if}
				{if in_array('store_desk_delete',$user_permissionArr)}
                <a href="{php echo manage_url(array('r'=>'desk','ac'=>'index','op'=>'delete','id'=>$item['id']))}" class="btn showtitle btn-default btn-sm" title="删除" onclick="return confirm('此操作不可恢复，确认删除？');return false;"><i class="fa fa-times"></i></a>
                {/if}
			</td>
		</tr>
		{/loop}
		{/if}
		</tbody>
	</table>
    {$pager}
</div>
<script type="text/javascript">
	require(['bootstrap'], function ($) {
        $('.showimg').hover(function () {
            $(this).popover('show');
        }, function () {
            $(this).popover('hide');
        });
        $('.showtitle').hover(function () {
            $(this).tooltip('show');
        }, function () {
            $(this).tooltip('hide');
        });
        $('.showpop').on('shown.bs.popover', function () {
            $('.showpop').not(this).popover('hide');
        });
        $('[data-toggle="popover"]').popover("destroy").popover({
            container: $(document.body)
        });
    });
</script>
{elseif $operation == 'post'}
<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" id="form" style="background: #fff;padding: 20px 0">
<input type="hidden" name="id" value="{$desk['id']}">
<input type="hidden" name="store_id" value="{$store_id}">
	<div class="form-group">
		<label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">桌号名称</label>
		<div class="col-md-9">
			<input type="text" name="name" class="form-control" value="{$desk['name']}" />
			<div class="help-block">如：一号桌</div>
		</div>
	</div>
	<div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
        <div class="col-sm-9 col-xs-12">
            <input type="submit" name="submit" value="提交" class="btn btn-primary" onclick="return formcheck()">
            <input type="hidden" name="token" value="{$_W['token']}">
    	</div>
    </div>
</form>
{/if}
</div>
</div>
{mtemplate '_footer'}